package com.ls.kdlss.views;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.ls.kdlss.R;


import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

/**
 * Created by cx on 7/29/15.
 */

@EViewGroup(R.layout.tab_selected_button)
public class TabSelectedButton extends RelativeLayout {


    private Context mContext;

    @ViewById
    TextView tv_tab_selected_text;
    @ViewById
    ImageView iv_tab_selected_img;


    public static TabSelectedButton getView(Context context) {
        return TabSelectedButton_.build(context);
    }

    public TabSelectedButton(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public TabSelectedButton(Context context) {
        super(context);
        init(context);
    }

    private void init(Context context) {

    }


    public void initData(int textRes, int imgRes) {
        tv_tab_selected_text.setText(textRes);
        iv_tab_selected_img.setImageResource(imgRes);
    }

    public boolean isChecked() {
        return iv_tab_selected_img.isSelected();
    }

    public void setChecked(boolean isChecked) {

        iv_tab_selected_img.setSelected(isChecked);
        tv_tab_selected_text.setSelected(isChecked);
        if (tv_tab_selected_text.isSelected())
            tv_tab_selected_text.setTextColor(getResources().getColor(R.color.bt_bbb));
        else
            tv_tab_selected_text.setTextColor(getResources().getColor(R.color.tv_tab_normal_text));

    }


    public String getText() {
        return tv_tab_selected_text.getText().toString();
    }


}
